package com.wa.annotations.lifecycle;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * 需要添加Component才会注入到spring中
 */
@Data
@AllArgsConstructor
@Component
public class LifeCycleInitializingBeanDisposableBean implements InitializingBean, DisposableBean {
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("LifeCycleInitializingBeanDisposableBean InitializingBean.afterPropertiesSet方法");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("LifeCycleInitializingBeanDisposableBean DisposableBean.destroy方法");
    }
}


